//
//  AllInvoiceViewCell.m
//  TeamInformatization
//
//  Created by Jessica on 2019/4/7.
//  Copyright © 2019 SPIC. All rights reserved.
//

#import "AllInvoiceViewCell.h"

@interface AllInvoiceViewCell()
// 标题
@property (nonatomic, strong) SimpleLabel *titleLabel;
// 状态
@property (nonatomic, strong) SimpleLabel *statusLabel;
// 描述
@property (nonatomic, strong) SimpleLabel *descriptionLabel;
@end


@implementation AllInvoiceViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatCellView];
        
        self.backgroundColor = [UIColor whiteColor];
        // 取消cell选中状态
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)creatCellView {
    UIView *devideView = [[UIView alloc] init];
    devideView.backgroundColor = kUIColorHex(0xF5F5F5);
    [self addSubview:devideView];
    [devideView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(kScreenWidth, 10 * kScaleHeight));
    }];
    
    self.titleLabel = [SimpleLabel initWithText:@"" TextColor:kUIColorHex(0x576B95) TextFont:[UIFont fontWithName:@"PingFangSC-Regular" size: 15] TextAlignment:NSTextAlignmentLeft];
    [self addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15 * kScaleWidth);
        make.top.mas_equalTo(devideView.mas_bottom).offset(14 * kScaleHeight);
        make.width.mas_equalTo(213 * kScaleWidth);
        make.height.mas_equalTo(21 * kScaleHeight);
    }];
    
    // 分割线
    UILabel *lineLabel = [[UILabel alloc] init];
    lineLabel.backgroundColor = kUIColorHex(0xF5F5F5);
    [self addSubview:lineLabel];
    [lineLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10 * kScaleHeight);
        make.left.mas_equalTo(self.titleLabel.mas_left);
        make.right.mas_equalTo(-15 * kScaleWidth);
        make.height.mas_equalTo(1);
    }];
    
    SimpleLabel *statusDescLabel = [SimpleLabel initWithText:@"状态:" TextColor:kTextAll102Color TextFont:[UIFont fontWithName:@"PingFangSC-Regular" size: 12] TextAlignment:NSTextAlignmentLeft];
    [self addSubview:statusDescLabel];
    [statusDescLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(lineLabel.mas_bottom).offset(10 * kScaleHeight);
        make.left.mas_equalTo(self.titleLabel.mas_left);
        make.width.mas_equalTo(36 * kScaleWidth);
        make.height.mas_equalTo(18 * kScaleHeight);
    }];
    
    self.statusLabel = [SimpleLabel initWithText:@"" TextColor:kTitleTextColor TextFont:[UIFont fontWithName:@"PingFangSC-Regular" size: 13] TextAlignment:NSTextAlignmentLeft];
    [self addSubview:_statusLabel];
    [_statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(statusDescLabel.mas_right).offset(1 * kScaleWidth);
        make.right.mas_equalTo(lineLabel.mas_right);
        make.centerY.mas_equalTo(statusDescLabel);
    }];
    
    SimpleLabel *descDescLabel = [SimpleLabel initWithText:@"描述:" TextColor:kTextAll102Color TextFont:[UIFont fontWithName:@"PingFangSC-Regular" size: 12] TextAlignment:NSTextAlignmentLeft];
    [self addSubview:descDescLabel];
    [descDescLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(statusDescLabel.mas_bottom).offset(6 * kScaleHeight);
        make.left.mas_equalTo(self.titleLabel.mas_left);
        make.width.mas_equalTo(36 * kScaleWidth);
        make.height.mas_equalTo(18 * kScaleHeight);
    }];
    
    self.descriptionLabel = [SimpleLabel initWithText:@"" TextColor:kTitleTextColor TextFont:[UIFont fontWithName:@"PingFangSC-Regular" size: 13] TextAlignment:NSTextAlignmentLeft];
    [self addSubview:_descriptionLabel];
    [_descriptionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(descDescLabel.mas_right).offset(1 * kScaleWidth);
        make.right.mas_equalTo(lineLabel.mas_right);
        make.centerY.mas_equalTo(descDescLabel);
    }];
}

-(void)setShowCellWithInvoice:(AllInvoice *)invoice {
    _titleLabel.text = invoice.title;
    _statusLabel.text = invoice.status;
    _descriptionLabel.text = invoice.descriptions;
}

@end
